import 'package:flutter/material.dart';

// 首页：放两个跳转按钮
class Home extends StatelessWidget {
  const Home({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('首页'),
        leading: const Icon(Icons.menu),
        centerTitle: true,
        actions: const [
          Icon(Icons.settings),
        ],
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () => Navigator.pushNamed(context, '/product'),
              child: const Text('商品列表'),
            ),
            ElevatedButton(
              onPressed: () => Navigator.pushNamed(context, '/product/1'),
              child: const Text('商品1'),
            ),
          ],
        ),
      ),
    );
  }
}

// 商品列表页
class Product extends StatelessWidget {
  const Product({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) =>
      Scaffold(appBar: AppBar(title: const Text('商品列表')));
}

// 商品详情页，带 id 参数
class ProductDetail extends StatelessWidget {
  final String id;
  const ProductDetail({Key? key, required this.id}) : super(key: key);
  @override
  Widget build(BuildContext context) =>
      Scaffold(appBar: AppBar(title: Text('商品详情 $id')));
}

// 404 页
class UnknownPage extends StatelessWidget {
  const UnknownPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) =>
      Scaffold(appBar: AppBar(title: const Text('404')));
}